//
//  ViewController.m
//  payDemo
//
//  Created by 魔龙 on 16/3/25.
//  Copyright © 2016年 魔龙. All rights reserved.
//

#import "ViewController.h"
#import "MLProduct.h"
#import "MLProductCell.h"
#import "MJExtension.h"

@interface ViewController ()
@property (nonatomic, strong) NSArray *products;
@end

@implementation ViewController

#pragma mark - 数据源方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.products.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    MLProductCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"productCell"];
    
    // 设置 Cell...
    cell.product = self.products[indexPath.row];
    return cell;
}

#pragma mark - 懒加载
- (NSArray *)products{
    if (_products == nil) {
        // 字典转模型
        self.products = [MLProduct mj_objectArrayWithFilename:@"tgs.plist"];
    }
    return _products;
}

@end
